/******************** 
	作用:资金管理
	作者:蔡俊雄
	修改:白菜
	版本:V1.0
	时间:2015-07-27
********************/

$(function() {
	var tableId = "#dynamic-table"; //表格ID

	General.initCheckbox(); //初始化表格中的复选框事件监听
	General.extendDialog(); //扩展对话框

	//点击
	$(tableId + ">tbody a[data-type]").on("click", function(e) {
		General.stopEvent(e);
		var tr = $(this).closest("tr");
		var id = tr.attr("data-id"); //用户id
		var nickName = tr.find("td:eq(1)").html();
		var type = $(this).attr("data-type"); //记录类型
		var title = "";
		var logUrl = "Fund?view=" + type;
		//				var logUrl = type + ".html?view=";
		switch (type) {
			case "change":
				title = "资金变更记录";
				break;
			case "chargeRecord":
				title = "充值记录";
				break;
			case "withdraw":
				title = "提现记录";
				break;
			case "shopping":
				title = "购物记录";
				break;
			case "commission":
				title = "返佣记录";
				break;
			case "integral":
				title = "积分记录";
				break;
			case "envelopes":
				title = "红包记录";
				break;
			case "freeze":
				title = "冻结账户";
				break;
			case "unfreeze":
				title = "取消冻结账户";
				break;
			case "recharge":
				title = "充值";
				break;
			default:
				break;
		}
		showReplyDialog(title, logUrl, id, type, nickName);
	});

	/**
	 * 弹出对应页面
	 * @param {String} title 标题
	 * @param {String} logUrl 地址
	 * @param {String} id 用户id
	 * @param {String} type 类型
	 * @param {String} nickName 昵称
	 */
	function showReplyDialog(title, logUrl, id, type, nickName) {
		var url = logUrl;
		if (type == "freeze"||type == "unfreeze") {
			if (type == "freeze")
				logUrl = "/finance/freeze/update"
			else
				logUrl = "/finance/canclFreeze/update"
			url=Common.addUrlParameters(logUrl, {
				"id": id,
				"nick": nickName
			});
		}else{
			url=Common.addUrlParameters(logUrl, {
				"id": id
			});
		}
		if (type == "recharge") {
			General.showDialogWidthHeight(title, url, 600, 436);
		} else if (type == "freeze") {
			General.showDialogWidthHeight(title, url, 400, 238);
		} else if (type == "unfreeze") {
			General.showDialogWidthHeight(title, url, 400, 210);
		} else {
			General.showDialogWidthHeight(title, url, 1000, 650);
		}
	}
});
